PUBLIC = ../../public
SRC = src
BIN = bin/debug
GLOBAL_BIN = ../../bin
CFLAGS = -Wall -pedantic -ansi -Werror
CC = gcc
LIB_TOOL = ar
LIB_FLAGS = -r -s
COMPILE_FLAG = -c

all: release 

debug: CFLAGS+=-g 
debug: BIN=bin/debug
debug: GLOBAL_BIN=../../bin/debug
debug: $(BIN)/Process1  $(BIN)/Process2 $(BIN)/Process3 clean
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		SUCCEFULY FINISHED			*"
	@echo "*							*"
	@echo "**********************************************************"


release: CFLAGS+=-O3 -DNDEBUG
release: BIN=bin/release
release: GLOBAL_BIN=../../bin/release
release: $(BIN)/Process1 $(BIN)/Process2 $(BIN)/Process3 clean
	@echo "**********************************************************"
	@echo "*							*"
	@echo "*		SUCCEFULY FINISHED			*"
	@echo "*							*"
	@echo "**********************************************************"

$(BIN)/Process1: Process1.o
	$(CC) $(CFLAGS) Process1.o -L$(GLOBAL_BIN) -lSharedMemory -lrt -lpthread -o $(BIN)/Process1

$(BIN)/Process2: Process2.o
	$(CC) $(CFLAGS) Process2.o -L$(GLOBAL_BIN) -lSharedMemory -lrt -lpthread -o $(BIN)/Process2

$(BIN)/Process3: Process3.o
	$(CC) $(CFLAGS) Process3.o -L$(GLOBAL_BIN) -lSharedMemory -lrt -lpthread -o $(BIN)/Process3


Process1.o: $(PUBLIC)/SharedMemory.h Process1.c
	$(CC) $(COMPILE_FLAG) $(CFLAGS) -I$(PUBLIC) Process1.c -o Process1.o

Process2.o: $(PUBLIC)/SharedMemory.h Process2.c
	$(CC) $(COMPILE_FLAG) $(CFLAGS) -I$(PUBLIC) Process2.c -o Process2.o

Process3.o: $(PUBLIC)/SharedMemory.h Process3.c
	$(CC) $(COMPILE_FLAG) $(CFLAGS) -I$(PUBLIC) Process3.c -o Process3.o

Exec:
	touch $(BIN)Test.scr;\
	echo "#!/bin/bash" > Test.scr; \
	echo ./$(BIN)/Process1 Yehuda Roth\&\ >>Test.scr; \
	echo ./$(BIN)/Process2\&\ >>Test.scr; \
	echo ./$(BIN)/Process3 >>Test.scr; \

clean: 
	rm *.o
